package com.neuedu.socket;

import java.io.*;
import java.net.Socket;
import java.sql.*;

public class MyClientSocket {

    public MyClientSocket() throws IOException {
        String host = "192.168.70.101";
        int port = 8888;
        Socket server = new Socket(host ,port);

        OutputStream os = server.getOutputStream();
        InputStream is = server.getInputStream();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));

        os.write("Hello Server  ".getBytes());
        os.flush();

//        char cs[] = new char[1024];
//        int i = 0;
//        while(is.available() != -1){
//            char ch = (char) is.read();
//            cs[i++] = ch;
//            if(ch == '\r'){
//
//            }
//            System.out.print(new String(cs,0,i));
//        }
        while(true){
            String line = bufferedReader.readLine();
            System.out.println("server:" + line);
        }
    }

    public static void main(String[] args) throws IOException, ClassNotFoundException, SQLException {
        new MyClientSocket();



    }

}
